﻿@using System.Web.Script.Serialization
@using Newtonsoft.Json
@{
    ViewBag.Title = "Select retraining endpoint";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<div class="row">
    <div class="col-md-12">
        <h2>Please select a <a href="http://azure.microsoft.com/en-us/documentation/articles/machine-learning-retrain-models-programmatically/" target="_blank"> retraining endpoint.</a></h2>
        <p>This endpoint represents the experiment you need to rerun your retraining data against.</p>
    </div>
</div>
<div class="row">
    <div class="col-md-4">Select web service</div>
    <div class="col-md-8"><select class="dropdown" data-bind="options: webServices,optionsText:'Name',value:selectedWebService"></select></div>
</div>
<div class="row">
    <div class="col-md-4">Select endpoint</div>
    <div class="col-md-8">
        <div data-bind="visible: selectedWebService">
            <select class="dropdown" data-bind="options: Endpoints,optionsText:'Name',value:selectedEndpoint"></select>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-md-4 col-md-offset-8">
        <a href="upload_data" class="btn btn-primary" role="button">Continue</a>
    </div>
</div>

<script type="text/javascript">
    var viewModel = {
        webServices: ko.observableArray(@Html.Raw(@ViewBag.WebServices)),
        selectedWebService : ko.observable(), // Nothing selected by default
        Endpoints : ko.observableArray(),
        selectedEndpoint : ko.observable()
    }
    viewModel.selectedWebService.subscribe(function(webService) {
        viewModel.Endpoints(webService.Endpoints);
        $.cookie("webService_train", webService.Id);
    });
     viewModel.selectedEndpoint.subscribe(function(endpoint) {
        $.cookie("endpoint_train", endpoint.Name);
    });
    ko.applyBindings(viewModel);
</script>